package com.atguigu.dga.meta.mapper;

import com.atguigu.dga.meta.bean.TableMetaInfo;
import com.atguigu.dga.meta.bean.TableMetaInfoVO;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 元数据表 Mapper 接口
 * </p>
 *
 * @author zhangchen
 * @since 2024-11-19
 */
@DS("dga")
@Mapper
public interface TableMetaInfoMapper extends BaseMapper<TableMetaInfo> {


    @Select("${sql}")
    public List<TableMetaInfoVO> getTableMetaInfoQuery(@Param("sql") String sql);

    @Select("${sql}")
    public  Integer getTableMetaTotalQuery(@Param("sql") String sql);

    @Select("select tm.id as tm_id,te.id as te_id," +
            "tm.create_time as tm_create_time ,te.create_time as te_create_time," +
            "tm.update_time as tm_update_time ,te.update_time as te_update_time," +
            "tm.*,te.* " +
            "  from table_meta_info tm left join  table_meta_info_extra te " +
            "  on  tm.table_name =te.table_name and tm.schema_name=te.schema_name " +
            "  where  assess_date=#{assessDate}")
    @ResultMap("resultMap")
    List<TableMetaInfo> selectTableMetaInfoListWithExtra(@Param("assessDate") String assessDate);
}
